package com.quoc.adapter;

import java.util.List;

import com.quoc.activity.R;
import com.quoc.model.OfficeModel;

import android.app.Activity;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class AdapterOffice extends BaseAdapter {
	public Activity activity;
	public List<OfficeModel> oList;
	public LayoutInflater inflater;
	

	public AdapterOffice(Activity activity, List<OfficeModel> list) {
		this.activity = activity;
		this.oList = list;
	}

	@Override
	public int getCount() {
		return oList.size();
	}

	@Override
	public Object getItem(int position) {
		return oList.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if(inflater==null)
			inflater=(LayoutInflater)activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
		if(convertView==null)
			convertView=inflater.inflate(R.layout.item_office, null);
		TextView txtName=(TextView)convertView.findViewById(R.id.txt_name);
		TextView txtMa=(TextView)convertView.findViewById(R.id.txt_ma);
		Log.i("21106", "size"+oList.size());
		OfficeModel mode= oList.get(position);
		
		Log.i("21106", "data "+mode.getMaPhong());
		txtMa.setText(mode.getMaPhong()+"");
		txtName.setText(mode.getTenPhong());
		return convertView;
	}

}
